﻿using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Diagnostics;


namespace wdwp.Desktop.widgetLib.CommonTypes
{
    /*************************************
     * 
     *          공통 자료형 모음 
     *      
     * ***********************************/



    /// <summary>
    /// 위젯 소스의 타입을 정의하는 열거형 
    /// </summary>
    public struct sWidgetTypes
    {
        /// <summary>
        /// 위젯타입 - 플래쉬
        /// </summary>
        public const string FLASH_WIDGET = "Flash";
        /// <summary>
        /// 위젯타입 - 실버라이트
        /// </summary>
        public const string AG_WIDGET = "Silverlight";
        /// <summary>
        /// 위젯타입 - 불분명하거나 제대로 되지않은 위젯
        /// </summary>
        public const string INVALID_WIDGET = "Invalid";
    };   

    /// <summary>
    /// 위젯 / 위젯 소스의 정보를 담는 구조체 
    /// </summary>
    [Serializable]
    public struct sWidgetInfo
    {
        private string m_Name;           //위젯 이름             
        private string m_FullHTMLUri;    //위젯 HTML 경로        
        private string m_Type;             //위젯 타입 (실버라이트/플래쉬)        
        private int m_Width;               //가로크기         
        private int m_Height;              //세로크기        
        private int m_StartX;              //시작위치        
        private int m_StartY;              //시작위치        
        private float m_Opacity;           //투명도


        /// <summary>
        /// 생성자
        /// </summary>
        public sWidgetInfo(string strName, int nHeight, int nWidth, string strType, string Path)
        {
            m_Opacity = 1.0F;
            m_StartX = 0;
            m_StartY = 0;

            m_Name = strName;
            m_Height = nHeight;
            m_Width = nWidth;
            m_Type = strType;

            m_FullHTMLUri = Path;
        }

        /// <summary>
        /// 생성자
        /// </summary>
        public sWidgetInfo(string strName, int nStartX, int nStartY, int nHeight, int nWidth, string strType, string Path)
            : this(strName, nHeight, nWidth, strType, Path)
        {
            m_StartX = nStartX;
            m_StartY = nStartY;
        }


        /// <summary>
        /// 위젯의 투명도
        /// </summary>
        public float Opacity
        {
            get { return m_Opacity; }
            set { m_Opacity = value; }
        }


        /// <summary>
        /// 위젯의 시작위치 Y 좌표
        /// </summary>
        public int StartY
        {
            get { return m_StartY; }
            set { m_StartY = value; }
        }

        /// <summary>
        /// 위젯의 시작위치 X 좌표
        /// </summary>
        public int StartX
        {
            get { return m_StartX; }
            set { m_StartX = value; }
        }

        /// <summary>
        /// 위젯의 길이
        /// </summary>
        public int Width
        {
            get { return m_Width; }
            set { m_Width = value; }
        }

        /// <summary>
        /// 위젯의 높이
        /// </summary>
        public int Height
        {
            get { return m_Height; }
            set { m_Height = value; }
        }

        /// <summary>
        /// 타입
        /// </summary>
        public string Type
        {
            get { return m_Type; }
            set { m_Type = value; }
        }


        /// <summary>
        /// 위젯의 이름
        /// </summary>
        public string Name
        {
            get { return m_Name; }
            set { m_Name = value; }
        }


        /// <summary>
        /// 위젯의 Full 경로
        /// </summary>
        public string FullHTMLUri
        {
            get { return m_FullHTMLUri; }
            set { m_FullHTMLUri = value; }
        }


        public override bool Equals(object obj)
        {
            if (((sWidgetInfo)obj).m_Name == this.m_Name &&
                ((sWidgetInfo)obj).m_Type == this.m_Type)
                return true;
            else
                return false;
        }

        public override int GetHashCode()
        {
            return this.ToString().GetHashCode();
        }


        public static bool operator ==(sWidgetInfo s1, sWidgetInfo s2)
        {
            return s1.Equals(s2);
        }

        public static bool operator !=(sWidgetInfo s1, sWidgetInfo s2)
        {
            return s1.Equals(s2);
        }

    };


    /// <summary>
    /// 위젯 프로세스 정보 
    /// </summary>
    public struct sWidgetProc
    {
        /// <summary>
        /// 위젯의 소스 정보
        /// </summary>
        public sWidgetInfo SrcInfo;        //위젯 소스 정보         
        private int wPID;              //실행한 위젯 프로세스 정보 
        private bool bEmpty;


        public sWidgetProc(sWidgetInfo srcInfo, int pID)
        {            
            bEmpty = false;
            SrcInfo = srcInfo;
            wPID = pID;
        }

        /// <summary>
        /// 위젯의 프로세스 ID
        /// </summary>
        public int procId
        {
            get
            {
                return wPID;
            }
        }

        public bool Empty 
        {
            get
            {
                return bEmpty;
            }
            set
            {
                bEmpty = value;
            }
        }
        
        public override bool Equals(object obj)
        {
            if (((sWidgetProc)obj).wPID == this.wPID &&
                ((sWidgetProc)obj).SrcInfo == this.SrcInfo)
                return true;
            else
                return false;
        }

        public override int GetHashCode()
        {
            return this.ToString().GetHashCode();
        }


        public static bool operator ==(sWidgetProc s1, sWidgetProc s2)
        {
            return s1.Equals(s2);
        }

        public static bool operator !=(sWidgetProc s1, sWidgetProc s2)
        {
            return !s1.Equals(s2);
        }

    };


}